﻿<cfsilent>
	<cfscript>
		
		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		
		event.setArg("pageTitle", "教学质量评价 - 评教指标体系");
		
		currentTab = event.getArg("TabID", "labList");
		
		/* 预设答案 */
		sql = "SELECT 
				m_id, options, measure, algorithm 
				FROM t_measure_set 
				WHERE m_id <> 'NOP'
				ORDER BY m_id ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		
		rs_measure = queryObj.execute( sql=sql ).getResult();
		
		passArgs = structNew();
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学质量评价</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>指标评判参考选项
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labList">class="active"</cfif> id="labList" tabTarget="List">预设评分标准</span>
						<span <cfif currentTab eq "labCreate">class="active"</cfif> id="labCreate" tabTarget="Create">新建评分标准</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>				
				</script>
				
				<div id="List" class="tabContent">
					
					<div class="noticeBlock">
						<h3>预设评分参考</h3>
						<hr/>
					</div>
					
					<cfif rs_measure.recordCount>
							
							<cfscript>
								
								/* 读取指定科目 */
								sql = "SELECT m_id, options, algorithm FROM query WHERE measure = :typeId ";
							
								queryObj = new Query( dbtype="query" );
								queryObj.setAttributes( query=rs_measure );
								queryObj.addParam( name="typeId", value="L", cfsqltype="cf_sql_char" );

								rs_type = queryObj.execute( sql=sql ).getResult();
								
							</cfscript>
							
							<cfif rs_type.recordCount >

								<div class="noticeBlock">
									<h2>阶段式指标</h2>
								</div>
								
								<cfset row = 0 />
								<table class="UIEditable">
									<thead>
										<tr>
											<td width="20"></td>
											<td width="100">算法</td>
											<td>选项</td>
											<td width="20"></td>
										</tr>
									</thead>
									<tbody>
										<cfloop query="rs_type">
											<cfset row++ />
											<cfset structInsert( passArgs, "MSET", rs_type.m_id, true ) />
											<tr class="editRows">
												<td class="index"><cfoutput>#row#</cfoutput></td>
												<td><span class="numeric"><cfoutput>#rs_type.algorithm#</cfoutput></span></td>
												<td><cfoutput>#rs_type.options#</cfoutput></td>
												<td><a href="<cfoutput>#buildURL('evaluateOptionRemoveDo', passArgs)#</cfoutput>" class="stat delete"></a></td>
											</tr>
										</cfloop>
										<cfset structDelete( passArgs, "MSET" ) />
									</tbody>
								</table>
								
							</cfif>
							
							<cfscript>
								
								/* 读取指定科目 */
								sql = "SELECT m_id, options, algorithm FROM query WHERE measure = :typeId ";
							
								queryObj = new Query( dbtype="query" );
								queryObj.setAttributes( query=rs_measure );
								queryObj.addParam( name="typeId", value="M", cfsqltype="cf_sql_char" );

								rs_type = queryObj.execute( sql=sql ).getResult();
								
							</cfscript>
							
							<cfif rs_type.recordCount >

								<div class="noticeBlock">
									<h2>分数式指标</h2>
								</div>
								
								<cfset row = 0 />
								<table class="UIEditable">
									<thead>
										<tr>
											<td width="20"></td>
											<td width="100">算法</td>
											<td>选项</td>
											<td width="20"></td>
										</tr>
									</thead>
									<tbody>
										<cfloop query="rs_type">
											<cfset row++ />
											<cfset structInsert( passArgs, "MSET", rs_type.m_id, true ) />
											<tr class="editRows">
												<td class="index"><cfoutput>#row#</cfoutput></td>
												<td><span class="numeric"><cfoutput>#rs_type.algorithm#</cfoutput></span></td>
												<td><cfoutput>#rs_type.options#</cfoutput></td>
												<td><a href="<cfoutput>#buildURL('evaluateOptionRemoveDo', passArgs)#</cfoutput>" class="stat delete"></a></td>
											</tr>
										</cfloop>
										<cfset structDelete( passArgs, "MSET" ) />
									</tbody>
								</table>
								
							</cfif>
							
						<cfelse>
						
							<div class="systemNotice">
								<p>您还没有设置任何评分参考指标</p>
							</div>
						
					</cfif>
					
				</div>
				
				<div id="Create" class="tabContent">
					
					<div class="noticeBlock">
						<h3>创建评分参考</h3>
						<hr/>
					</div>
					
					<form id="formMeasure" onSubmit="javascript:return processVerfiyForm('formMeasure');" class="formWrapper" method="post" action="<cfoutput>#buildURL('evaluateOptionCreateDo')#</cfoutput>">
						
						<div class="label">
							<b>指标类别</b>
							
							<div class="secondRow">
								<input id="opt_L" name="Measure" value="L" type="radio" checked="checked" class="typeRadio" /> 预设选项
								<p class="notice">将观测点结论预设为多个选项, 根据选项计数计算指标好评率</p>
							</div>
							<div class="secondRow">
								<input id="opt_M" name="Measure" value="M" type="radio" class="typeRadio" /> 百分制打分
								<p class="notice">将观测点指标设置为百分制分数</p>
							</div>
							
						</div>
						
						<hr/>
						
						<div class="label">
							<b>计算模式</b>
							<div class="secondRow" id="div_GPA">
								<input name="AlgoModel" value="GPA" type="radio" class="typeRadio" /> 线性计算
								<p class="notice">将各选项按照百分比计算, 可自定义各选项权重, 控制计算结果</p>
							</div>
							<div class="secondRow" id="div_GPR">
								<input name="AlgoModel" value="GPR" type="radio" checked="checked" class="typeRadio" /> 指数计算
								<p class="notice">将各选项按照指数进行加权计算, 排名越前权重越高, 计算百分比结果时更趋于正态分布</p>
							</div>
							<div class="secondRow hidden_elem" id="div_AVG">
								<input name="AlgoModel" value="AVG" type="radio" class="typeRadio" /> 平均分
								<p class="notice">根据选项得分情况, 计算平均得分</p>
							</div>
						</div>
						
						<div class="label" id="div_OPT">
							<b>预设选项</b>
							<input name="optCount" id="optCount" type="hidden" value="2"/>
							<div class="secondRow">
								<table id="optTable">
									<tr>
										<td><a id="optTrigger" href="javascript:void(0);">＋</a></td>
										<td>选项</td>
										<td>权重</td>
									</tr>
									<cfloop from="1" to="2" index="i">
									<tr>
										<td class="numeric"><cfoutput>#i#</cfoutput></td>
										<td>
											<input name="OptionName<cfoutput>#i#</cfoutput>" verification="required" type="text" class="typeTextShort" maxlength="30" value="选项<cfoutput>#i#</cfoutput>" />
										</td>
										<td>
											<input name="OptionWeight<cfoutput>#i#</cfoutput>" verification="integer" type="text" class="typeTinyInt" maxlength="3" value="1" />
										</td>
									</tr>
									</cfloop>
								</table>
							</div>
						</div>

						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="添加" />
						</div>
						
					</form>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$("#formMeasure").ready(function() {
							
							$("#optTrigger").click(function(){
							
								var optcount = $("#optCount").val();
								
								var nextIdx = parseInt(optcount) + 1;
								
								var $table = $("#optTable");
								var $row = $("<tr><td class='numeric'>" + nextIdx + "</td><td><input name='OptionName" + nextIdx + "' verification='required' type='text' class='typeTextShort' maxlength='30' value='选项" + nextIdx + "' /></td><td><input name='OptionWeight" + nextIdx + "' verification='integer' type='text' class='typeTinyInt' maxlength='3' value='1' /></td></tr>");
								
								$row.appendTo($table);
								
								$("#optCount").val(nextIdx);
								
							});

							$("#opt_L").change(function(){
								
								$("input[name='AlgoModel']").removeAttr("checked");
								
								var checked = $(this).prop("checked");
								
								if ( checked ) {
									
									$("#div_AVG").addClass("hidden_elem");

									$("#div_OPT").removeClass("hidden_elem");
									$("#div_GPA").removeClass("hidden_elem");
									$("#div_GPR").removeClass("hidden_elem");
									
									$("#div_GPR > input[name='AlgoModel']").attr("checked", "checked");

								}

							});

							$("#opt_M").change(function(){
								
								$("input[name='AlgoModel']").removeAttr("checked");
								
								var checked = $(this).prop("checked");
								
								if ( checked ) {
									
									$("#div_AVG").removeClass("hidden_elem");

									$("#div_GPA").addClass("hidden_elem");
									$("#div_GPR").addClass("hidden_elem");
									$("#div_OPT").addClass("hidden_elem");
									
									$("#div_AVG > input[name='AlgoModel']").attr("checked", "checked");

								}
								
							});
							
						});
						// -->
						//]]>				
					</script>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>